let d = [];
/*变量 最好更改
****baoqingwl.url
****baoqingwl.fl
****baoqingwl.classify
*
*需修改
****翻页  true_url
****列表 fl classify
****分类  sub_classify
*/
//自定义颜色
  const Color="#FA7298";
  
  const a=MY_URL.replace(/%%/g, "");
  let true_url = getVar("baoqingwl.url", a)
  

//setError(page);

//翻页 根据实际替换
  true_url = true_url.replace(f_page, r_page) 
   
//setError(true_url);  
  const html = fetch(true_url)
  const empty = "hiker://empty"
//获取列表 
  const fl = parseDomForArray(html,fl_selector);//四大金刚
  const classify = parseDomForArray(html, classify_selector);//其他分类列表



  let init_cate = []
  for (let i = 0; i < 20; i ++) {
    init_cate.push("0")
  }
  const fold = getVar("baoqingwl.fold", "0")
  // 取四金刚缓存

  const cate_temp_json = getVar("baoqingwl.fl", JSON.stringify(init_cate))
  const cate_temp = JSON.parse(cate_temp_json)

  // 取缓存

  const classify_json = getVar("baoqingwl.classify", JSON.stringify(init_cate))
  const classify_temp = JSON.parse(classify_json)

  if (parseInt(page) === 1) {
  d.push({
        title: fold === '1' ? '““””<b><span style="color: #FF0000">∨</span></b>' : '““””<b><span style="color: #1aad19">∧</span></b>',
        url: $(empty).lazyRule((fold) => {
            putVar("baoqingwl.fold", fold === '1' ? '0' : '1');
            refreshPage(false);
            return "hiker://empty"
        }, fold),
        col_type: 'scroll_button',
    })
   fl.forEach((category, index) => {
    //四大金刚的分类	
      let sub_classify = parseDomForArray(category,fl_sub_selector);////需修改
       sub_classify.forEach((item, key) => {
          let title = parseDomForHtml(item, 'a&&Text')
          d.push({
            title: key.toString()===cate_temp[index]?'““””<b><font color='+Color+'>'+title+' </font></b>':title,
            url: $(parseDom(item, 'a&&href')).lazyRule((params) => {
              params.cate_temp[params.index] = params.key.toString()
              putVar("baoqingwl.fl", JSON.stringify(params.cate_temp))
              putVar("baoqingwl.url", input)
              refreshPage(true)
              return "hiker://empty"
            }, {
              cate_temp: cate_temp,
              index: index,
              key: key,
              page: page,
            }),
            col_type: 'scroll_button',
          })
        })
       d.push({
          col_type:"blank_block"
        });
    })
    
if(fold==='1') {
//其他分类
    classify.forEach((category, index) => {
      let sub_classify = parseDomForArray(category, classify_sub_selector);////需修改
        sub_classify.forEach((item, key) => {
          let title = parseDomForHtml(item, 'a&&Text')
         if (title !== '' ) { 
          d.push({
            title: key.toString()===classify_temp[index]?'““””<b><font color='+Color+'>'+title+' </font></b>':title,
            url: $(parseDom(item, 'a&&href')).lazyRule((params) => {
              params.classify_temp[params.index] = params.key.toString()
              putVar("baoqingwl.classify", JSON.stringify(params.classify_temp))
              putVar("baoqingwl.url", input)
              refreshPage(true)
              return "hiker://empty"
            }, {
              classify_temp: classify_temp,
              index: index,
              key: key,
              page: page,
            }),
            col_type: 'scroll_button',
          })
           }
        })
       d.push({
          col_type:"blank_block"
        });
    })

}


  }
  
var list = parseDomForArray(html,list_selector);
var urls=getUrl().match(/https?:\/\/.*?\//);
var domain =urls[0].substring(0,urls[0].length-1);
    for (var i in list) {
        var title = parseDomForHtml(list[i], title_selector);
        var img = parseDom(list[i], img_selector)+'@Referer='+domain;
        var url = parseDom(list[i], url_selector);
        var desc = parseDomForHtml(list[i], desc_selector);
        d.push({
            title: title,
            pic_url: img,
            url: url,
            desc: desc
        });
    }
res.data = d;
setHomeResult(res); 
